<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        function fn(arr){
            
            var temp;
            for(var i=0;i<arr.length;i++)
            {
                var min=111111111;
                for(var j=i;j<arr.length;j++)
                {
                    if(arr[j]<min)
                    {
                        min=arr[j];
                        temp=j;
                    }
                }
                
                arr[temp]=arr[i];
                arr[i]=min;
            }
            console.log(arr)
        }
        fn([1,8,2,6,4,3,15,7,9,10,5,100])
    </script>
</body>
</html>